package com.design.adapter.football;

/**
 * @author xiemiao
 * @description 翻译官
 * @date 2023/08/15
 */
public class Translator implements Coaches {
    private ForeignCoaches foreignCoaches;

    public Translator(ForeignCoaches foreignCoaches) {
        this.foreignCoaches = foreignCoaches;
    }

    @Override
    public void communicate(String action) {
        String translate = translate(action);
        foreignCoaches.instruct(translate);
    }

    private String translate(String action) {
        // 在实际应用中，这里可以根据需要进行语言翻译
        if (action.equals("pass")) {
            return "传球";
        } else if (action.equals("shoot")) {
            return "射门";
        } else if (action.equals("goal")) {
            return "进球";
        }
        return action;
    }
}
